/*    */ package dm.jdbc.driver;
/*    */ 
/*    */ import dm.jdbc.dbaccess.DBError;
/*    */ import dm.jdbc.dbaccess.DmMsgSend;
/*    */ import dm.jdbc.desc.ParameterDesc;
/*    */ import dm.sql.TypeData;
/*    */ import dm.sql.TypeDescriptor;
/*    */ import java.sql.Blob;
/*    */ import java.sql.SQLException;
/*    */ 
/*    */ 
/*    */ public class DmBlobBinder
/*    */   extends DmBinder
/*    */ {
/* 15 */   boolean new_lob_flag = false;
/*    */   
/*    */   public DmBlobBinder(DmdbPreparedStatement_bs pstmt) {
/* 18 */     super(pstmt);
/* 19 */     this.new_lob_flag = pstmt.getConnection_bs().getNewLobFlag();
/*    */   }
/*    */   
/*    */   void init() {
/* 23 */     this.recDType = 12;
/* 24 */     this.recPrec = Integer.MAX_VALUE;
/* 25 */     this.recScale = 0;
/*    */   }
/*    */   
/*    */   public int bindData(DmMsgSend msg, int irow, int icol, boolean forBatch) throws SQLException
/*    */   {
/* 30 */     Blob blob = ((Blob[])this.pstmt.m_paramObjects[icol])[irow];
/* 31 */     TypeDescriptor typeDesc = this.paramsDesc[icol].getTypeDescriptor();
/*    */     
/* 33 */     long length = blob.length();
/* 34 */     if ((this.destDType == 12) && 
/* 35 */       (length > 2048L)) {
/* 36 */       return -1;
/*    */     }
/*    */     
/* 39 */     byte[] ret = null;
/* 40 */     switch (this.destDType) {
/*    */     case 12: 
/* 42 */       ret = blob.getBytes(1L, (int)length);
/* 43 */       if (ret == null)
/* 44 */         ret = new byte[0];
/* 45 */       break;
/*    */     
/*    */     case 117: 
/*    */     case 119: 
/*    */     case 121: 
/*    */     case 122: 
/* 51 */       if (typeDesc != null) {
/* 52 */         byte[] lobBuf = blob.getBytes(1L, (int)length);
/* 53 */         ret = TypeData.objBlobToBytes(lobBuf, typeDesc);
/*    */       } else {
/* 55 */         DBError.throwSQLException(6007); }
/* 56 */       break;
/*    */     
/*    */     default: 
/* 59 */       DBError.throwSQLException(6007);
/*    */     }
/*    */     
/* 62 */     return msg.appendBytesWithLen2(ret, 0, ret.length);
/*    */   }
/*    */   
/*    */   public int bindLobCyc(DmMsgSend lobMsg, int irow, int icol) throws SQLException
/*    */   {
/* 67 */     Blob lob = ((Blob[])this.pstmt.m_paramObjects[icol])[irow];
/* 68 */     int maxLen = 16000;
/*    */     
/* 70 */     if (this.offset_var > lob.length()) {
/* 71 */       clearVars();
/* 72 */       return 0;
/*    */     }
/*    */     
/* 75 */     if (this.offset_var == -1) {
/* 76 */       this.offset_var = 1;
/*    */     }
/* 78 */     byte[] ret = lob.getBytes(this.offset_var, maxLen);
/* 79 */     this.offset_var += ret.length;
/*    */     
/* 81 */     return lobMsg.appendOffRowBytes(ret, 0, ret.length, this.new_lob_flag, -1);
/*    */   }
/*    */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmBlobBinder.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */